package com.rcmd.cmd;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

public class FileCommand extends Command{
	public enum ACTION{GET, PUT};
	private ACTION action ;
	private String fileServer ;
	private String fileClient ;

	public String getFileServer() {
		return fileServer;
	}
	public void setFileServer(String fileServer) {
		this.fileServer = fileServer;
	}
	public String getFileClient() {
		return fileClient;
	}
	public void setFileClient(String fileClient) {
		this.fileClient = fileClient;
	}
	public FileCommand(String cmd){
		super(Command.FILE) ;
	}
	public FileCommand(){
		this("") ;
	}
	public ACTION getAction() {
		return action;
	}
	public void setAction(ACTION action) {
		this.action = action;
	}
	  
	
	@Override
	protected void read(ObjectInput in) throws IOException,
			ClassNotFoundException {
		action=ACTION.values()[in.readInt()] ;
		this.fileServer = in.readUTF();
		this.fileClient = in.readUTF() ;
	}
	@Override
	protected void write(ObjectOutput out) throws IOException {
		out.writeInt(action.ordinal()) ;
		out.writeUTF(fileServer==null?"":fileServer) ;
		out.writeUTF(fileClient==null?"":fileClient) ;

	}
}
